package com.leoman.plz_p.presenter;


import com.leoman.plz_p.interfaces.MissionDetailView;
import com.leoman.plz_p.module.api.CourseApi;
import com.leoman.plz_p.module.bean.BaseData;
import com.leoman.plz_p.module.bean.MapData;
import com.leoman.plz_p.subscriber.ResponseSubscriber;
import com.leoman.plz_p.utils.UserHelper;

import cn.com.corelib.api.ResponseTransformer;
import cn.com.corelib.base.BasePresenter;

public class MissionDetailPresenter extends BasePresenter<MissionDetailView> {

    private CourseApi courseApi;

    @Override
    protected void onViewAttach() {
        super.onViewAttach();
        courseApi=getApi(CourseApi.class);
    }

    public void getMissionList(String id){
        getView().showLoading();
        courseApi.getMissionBook(UserHelper.getToken(),id)
                .compose(new ResponseTransformer<>(this.<BaseData<MapData>>bindToLifeCycle()))
                .subscribe(new ResponseSubscriber<BaseData<MapData>>(view) {
                    @Override
                    public void success(BaseData<MapData> data) {
                        view.obtainMissionDetail(data.data.taskList);
                    }
                });
    }

    @Override
    public void onStart() {

    }
}